import Mock from 'mockjs'

Mock.mock('/api/message', 'post', {
	code: 0,
	msg: '',
	data: {
		id: '@guid',
		nickname: '@cname',
		content: '@cparagraph(1, 10)',
		createDate: Date.now(),
		'avatar|1': [
			'https://thirdwx.qlogo.cn/mmopen/lY1apO4V1N8icEoYVM025Zdic9nicZW11wrq2S33aAPPTj8hy6e5ZvQ7ptfW9LmhPUB5Zj5NDaN32zQwZzXEMFOMqYvFQ4cmRbZ/132',
			'https://thirdqq.qlogo.cn/g?b=oidb&k=oibibVTMPGfhVQMzWzuwKIdQ&s=40&t=1651660980',
			'https://thirdqq.qlogo.cn/g?b=oidb&k=iavABgZ4vAFmbepUmFNuo5g&s=40&t=1645374831',
			'https://thirdqq.qlogo.cn/g?b=oidb&k=PayKibCaw2r2P6h0zS8XAJQ&s=40&t=1565963848',
		],
	},
})

Mock.mock(/^\/api\/message\/?(\?.+)?$/, 'get', function (options) {
	const queryparam = new URLSearchParams(options.url)

	return Mock.mock({
		code: 0,
		msg: '',
		data: {
			total: 52,
			[`rows|${queryparam.get('limit') || 10}`]: [
				{
					id: '@guid',
					nickName: '@cname',
					content: '@cparagraph(1, 10)',
					createDate: Date.now(),
					'avatar|1': [
						'https://thirdwx.qlogo.cn/mmopen/lY1apO4V1N8icEoYVM025Zdic9nicZW11wrq2S33aAPPTj8hy6e5ZvQ7ptfW9LmhPUB5Zj5NDaN32zQwZzXEMFOMqYvFQ4cmRbZ/132',
						'https://thirdqq.qlogo.cn/g?b=oidb&k=oibibVTMPGfhVQMzWzuwKIdQ&s=40&t=1651660980',
						'https://thirdqq.qlogo.cn/g?b=oidb&k=iavABgZ4vAFmbepUmFNuo5g&s=40&t=1645374831',
						'https://thirdqq.qlogo.cn/g?b=oidb&k=PayKibCaw2r2P6h0zS8XAJQ&s=40&t=1565963848',
					],
				},
			],
		},
	})
})
